global K productionRateFnc k1 k2;

%Arreglar codigo en algun momento
%----------------------------------------------------------------
%para que estabilice asintoticamente
lambda1 = -1.2; lambda2 = -1.8;

%para que estabilice de forma oscilatoria
%lambda1 = -1.2 + 5i; lambda2 = -1.2 - 5i;
%----------------------------------------------------------------

%1 es inventario, 2 es ventas
plotType = 2;

KArray = [0.1,0.8,2,4,7];

%productionRateFnc = @controledProductionRate;
productionRateFnc = @stateVariablesProductionRate;

plotConfs = ['k: '; 'k- '; 'k--'; 'k. '; 'k.-'];

hold on;

kList = zeros(length(kArray), 2);

for i=1:length(kArray)
    K = KArray(i);
    
    %las k chicas varian segun el K grande
    k2 = (lambda1 * lambda2 - 6 - K * (- lambda1 - lambda2)) / (K^2 + 6);
    k1 = (- lambda1 - lambda2) + K * k2;
    kList(i, :) = [k1, k2];
    
    [t,x] = ode45(@model3, [0,10], [30, 10], odeset('maxstep', 1, 'reltol', 1e-4, 'abstol', 1e-3));
    plot(t, x(:,plotType), plotConfs(i, :));
    %max(x(:,plotType))
end

xlabel('t');
if plotType == 1
    ylabel('Inventario');
else
    ylabel('Ventas');
end
legend('K = 0.1', 'K = 0.8', 'K = 2', 'K = 4', 'K = 7', 'Location', 'SouthEast');

hold off;
